class Point
  attr_reader :x, :y

  def initialize(x, y)
    @x = x
    @y = y
  end

  def distance(point)
    Math.sqrt((@x - point.x)**2 + (@y - point.y)**2)
  end
end

class Array
  def avg
    self.inject(0) {|s,v| s + v} / self.size.to_f
  end

  def std_dev
    Math.sqrt(variance)
  end

  def variance
    n = 0
    mean = 0.0
    s = 0
    self.each do |x|
      n += 1
      delta = x - mean
      mean += delta / n
      s += delta * (x - mean)
    end

    (s / (n - 1))
  end
end
